package edu.washington.cs.sounddetector.server.api.methodresult;

import edu.washington.cs.sounddetector.server.api.MethodResult;
import edu.washington.cs.sounddetector.server.api.method.SetSoundClassProperties;

public class SetSoundClassPropertiesResult extends MethodResult<SetSoundClassProperties>
{

    private String detectorId;
    private String soundClass;

    private SetSoundClassPropertiesResult(boolean successful, FailureReason reason,
            String detectorId, String soundClass)
    {
        super(successful, reason);
        this.detectorId = detectorId;
        this.soundClass = soundClass;
    }

    private SetSoundClassPropertiesResult()
    {
        this(true, null, null, null);
    }

    /**
     * @return if {@link #isSuccessful()} returns false and {@link #getReason()} is
     *         DETECTOR_ID_DOES_NOT_EXIST, returns the detectorId that does not exist. If
     *         {@link #isSuccessful()} returns true, returns null.
     */
    public String getDetectorId()
    {
        return detectorId;
    }

    /**
     * @return if {@link #isSuccessful()} returns false and {@link #getReason()} is
     *         SOUND_CLASS_DOES_NOT_EXIST, returns the soundClass that does not exist. If
     *         {@link #isSuccessful()} returns true, returns null.
     */
    public String getSoundClass()
    {
        return soundClass;
    }

    public static SetSoundClassPropertiesResult success()
    {
        return new SetSoundClassPropertiesResult(true, null, null, null);
    }

    public static SetSoundClassPropertiesResult failureDetectorIdDoesNotExist(String detectorId)
    {
        return new SetSoundClassPropertiesResult(false, FailureReason.DETECTOR_ID_DOES_NOT_EXIST,
                detectorId, null);
    }

    public static SetSoundClassPropertiesResult failureSoundClassDoesNotExist(String soundClass)
    {
        return new SetSoundClassPropertiesResult(false, FailureReason.SOUND_CLASS_DOES_NOT_EXIST,
                null, soundClass);
    }
}
